package br.fatec.webservice.model;

import java.io.ByteArrayOutputStream;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

@Root
public class Cliente 
{
	@Attribute
	private Integer codigo;
	
	@Element
	private String nome;
	
	@Element
	private String usuario;
	
	@Element
	private String senha;
	
	public Integer getCodigo() {
		return codigo;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}
	
	public String getUsuario() {
		return usuario;
	}

	public void setUsuario(String usuario) {
		this.usuario = usuario;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}
	
	public String getXml() throws Exception
	{
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		Serializer serializer = new Persister();
		
		String schema = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";

		serializer.write(this, os);

		schema += os.toString("UTF-8");

		return schema;
	}
}
